<Window x:Class="P2.Cuberry.Modules.SimpleAccounting.FiTransaction.FiChequeEditDetailsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:basec="clr-namespace:P2.Cuberry.Framework.Helper;assembly=P2.Cuberry.Framework.Helper" 
       
  xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  xmlns:is="http://schemas.microsoft.com/expression/2010/interactions"
        Icon="/P2.Cuberry;component/Images/CuberryIcon32.ico"
        Title="Peacequare Cuberry" Width="750" Height="580"  
        Background="{DynamicResource P2BackgroundBrush}" 
        Closing="Window_Closing" Focusable="True" IsManipulationEnabled="True" xmlns:my="clr-namespace:P2.Cuberry.Modules.SimpleAccounting.FiAccount;assembly=P2.Cuberry.Modules.SimpleAccounting.FiAccount" xmlns:my1="clr-namespace:P2.Cuberry.Modules.SimpleAccounting.FiTransaction">

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/P2.Cuberry.Framework.Layout;component/Styles/Styles.xaml"/>
                <ResourceDictionary Source="/P2.Cuberry.Framework.Layout;component/Styles/CuberryDataGrid.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Grid Loaded="Grid_Loaded">
        <Grid.Resources>
            <Image x:Key="CancelIcon" Height="16" Width="16" Source="/P2.Cuberry.Modules.SimpleAccounting.FiTransaction;component/Images/Cancel16.gif" />
            <Image x:Key="PaidIcon" Height="16" Width="16" Source="/P2.Cuberry.Modules.SimpleAccounting.FiTransaction;component/Images/book16.gif" />
            <Image x:Key="ReOpenIcon" Height="16" Width="16" Source="/P2.Cuberry.Modules.SimpleAccounting.FiTransaction;component/Images/ReOpen2.png" />

            <Image x:Key="OpenTransactionIcon" Height="15" Width="12" Source="/P2.Cuberry.Modules.SimpleAccounting.FiCheque;component/Images/OpenTransaction2.png" />
        </Grid.Resources>


        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="35" />
            <RowDefinition Height="*"/>
            <RowDefinition Height="35" />

        </Grid.RowDefinitions>

        <!-- Row 0 Start -->
        <Label Grid.Row="0" Grid.Column="0"  Content="{Translate DialogHeaderEditFiChequeDetail}" Style="{StaticResource P2DetailViewHeaderTextStyle}" />

        <Separator Margin="0,0,0,0" Grid.Row="0" Grid.Column="0"  VerticalAlignment="Bottom" Height="0"/>
        <!-- Row 0 End -->

        <!-- Row 1: Menu Start -->
        <Border  Grid.Row="1" Grid.Column="0"  Style="{StaticResource P2MenuBorderStyle}">
            <Grid>
                <Menu Grid.Row="1" x:Name="menuMain" Style="{StaticResource P2MenuStyle}" >

                    <MenuItem x:Name="SaveBtn" Margin="2,1,0,2"  InputGestureText="Ctrl+S"   Header="{Translate SaveBtn}" Command="{Binding FiChequeSaveCommand}"  Style="{StaticResource P2MenuItemStyleSave}" IsManipulationEnabled="True" />
                    <!--<MenuItem x:Name="SaveBtn" Margin="2,1,0,2"  Visibility="Visible"  InputGestureText="Ctrl+S" Header="{Translate SaveBtn}" Command="{Binding FiChequeSaveCommand}"  Style="{StaticResource P2MenuItemStyleSave}" Focusable="False" />-->
                    <MenuItem x:Name="CloseBtn" Margin="2,1,0,2" InputGestureText="Ctrl+X" Header="{Translate SaveAndCloseBtn}" Command="{Binding FiChequeCloseCommand}" Style="{StaticResource P2MenuItemStyleSaveAndClose}"/>

                </Menu>
                <Menu Grid.Row="1" HorizontalAlignment="Right" x:Name="menuMainRight" Style="{StaticResource P2MenuStyle}" >
                    <MenuItem x:Name="HistoryBtn" Command="{Binding HistoryCommand}"  Style="{StaticResource P2MenuItemStyleHistory}"/>
                    <MenuItem x:Name="InfoBtn" Command="{Binding InfoCommand}"  Style="{StaticResource P2MenuItemStyleInfo}"/>
                </Menu>

            </Grid>
        </Border>


        <!-- Row 1 End -->

        <!-- Row 2: All Fields -->
        <Border  Grid.Row="2" Grid.Column="0"  Style="{StaticResource P2ContentBorderStyle}">
            <Grid Grid.Row="2" Grid.Column="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="604*"/>
                    <ColumnDefinition Width="0*" />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="95"/>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="65"/>
                </Grid.RowDefinitions>



                <Label Margin="4,6,0,0" Name="ChequeNoL" Height="28" VerticalAlignment="Top" Content="{Translate ChequeNoL}" HorizontalAlignment="Left" Width="85"></Label>
                <TextBox Margin="94,9,0,0" Name="ChequeNo" Height="23" Text="{Binding ChequeNo, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}"  
Style="{StaticResource P2TextBoxStyle}" VerticalAlignment="Top" HorizontalAlignment="Left" Width="150" />

                <Label Margin="4,35,0,0" Name="AmountL" Height="28" VerticalAlignment="Top" Content="{Translate AmountL}" HorizontalAlignment="Left" Width="85"></Label>
                <TextBox Margin="94,38,0,0" Name="Amount" Height="23" Text="{Binding Amount, StringFormat=N2, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}"  
                Style="{StaticResource P2TextBoxStyle}" VerticalAlignment="Top" HorizontalAlignment="Left" Width="150" HorizontalContentAlignment="Right" FlowDirection="LeftToRight" GotFocus="Amount_GotFocus" PreviewMouseLeftButtonDown="SelectAll"/>


                <Label Margin="257,4,0,0" Name="BankL" Height="28" VerticalAlignment="Top" Content="{Translate BankL}" HorizontalAlignment="Left" Width="85"></Label>
                <TextBox Margin="347,7,0,0" Name="Bank" Height="23" Text="{Binding Bank, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}"  
                Style="{StaticResource P2TextBoxStyle}" VerticalAlignment="Top" HorizontalAlignment="Left" Width="150" />

                <Label Margin="257,35,0,0" Name="MyBankL" Height="28" VerticalAlignment="Top" Content="{Translate MyBankL}" HorizontalAlignment="Left" Width="85"></Label>
                <TextBox Margin="347,38,0,0" Name="MyBank" Height="23" Text="{Binding MyBank, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}"  
                Style="{StaticResource P2TextBoxStyle}" VerticalAlignment="Top" HorizontalAlignment="Left" Width="150" />

                <Label Margin="518,62,0,0" Content="{Translate CurrencyIDL}" Name="CurrencyIDL" Height="28" VerticalAlignment="Top" HorizontalAlignment="Left" Width="85" />
                <ComboBox Margin="608,65,0,0" DisplayMemberPath="XConfigCurrencyCur" Name="CurrencyID" SelectedValuePath="CurrencyID" SelectedValue="{Binding CurrencyID,  
                ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" ItemsSource="{Binding XConfigCurrencys}" IsEnabled="{Binding IsEditable}" Style="{StaticResource P2ComboBoxStyle}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}" Height="23" VerticalAlignment="Top" HorizontalAlignment="Left" Width="100" />



                <Label Margin="518,35,0,0" Name="ValueDateL" Height="28" VerticalAlignment="Top" Content="{Translate ValueDateL}" HorizontalAlignment="Left" Width="85"></Label>
                <DatePicker Margin="608,35,0,0" Name="ValueDate" Height="23" SelectedDate="{Binding ValueDate, Mode=TwoWay}"  
                xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" HorizontalAlignment="Left" Width="100"  VerticalAlignment="Top" />



                <Label Grid.Row="2" Margin="10,0,0,43" Name="NoteL" Content="{Translate NoteL}" HorizontalAlignment="Left" Width="84" Height="28" VerticalAlignment="Bottom"></Label>
                <TextBox Grid.Row="2" Margin="5,0,5,5" Name="Note" Height="43" HorizontalAlignment="Stretch"  VerticalAlignment="Bottom" VerticalScrollBarVisibility="Auto" Style="{StaticResource P2TextBoxStyle}"
                         Text="{Binding Note , ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                         IsReadOnly="{Binding NameReadOnly}"
                         />


                <Label Margin="518,6,0,0" Name="FiscalYearIDL" Height="28" VerticalAlignment="Top" Content="{Translate FiscalYearIDL}" HorizontalAlignment="Left" Width="85"></Label>
                <ComboBox  Margin="608,8,0,0" Name="FiscalYear" ItemsSource="{Binding FiscalYears}"
                          SelectedValue="{Binding FiscalYearID, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}" Style="{StaticResource P2ComboBoxStyle}" SelectedValuePath="FiscalYearID" DisplayMemberPath="FiscalYearName" 
                           VerticalAlignment="Top"  IsEnabled="False" HorizontalAlignment="Left" Width="100" />



                <Grid Grid.Row="1" Grid.Column="0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>


                    <Border Grid.Row="0" Margin="5,0,5,5"   VerticalAlignment="Stretch" BorderThickness="1" CornerRadius="2,2,2,2" BorderBrush="#FF6893CF">
                        <Grid ShowGridLines="False">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20"/>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="34"/>
                            </Grid.RowDefinitions>

                            <Label Grid.Row="0" Name="DebitL" Width="120" Height="28"  VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0" Content="{Translate DebitL}" FontWeight="Bold" />

                            <DataGrid Grid.Row="1"  Margin="3,0,3,0" 
                                         Name="FiChequeFiTransactionItemDebitList" 
                                         ItemsSource="{Binding FiChequeDebitTransactionItems}"                                                                   
                                         Style="{DynamicResource CuberryDataGridStyle}"
                                     
                                         VerticalAlignment="Top" >

                             

                                <DataGrid.RowStyle>
                                    <Style TargetType="DataGridRow">
                                        <Setter Property="IsEnabled" Value="{Binding Path=FiTransactionItemCheckForReadOnly,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" />
                                      
                                        <Style.Triggers>
                                            <Trigger Property="IsEnabled" Value='false'>
                                                <Setter Property="Background" Value="LightGray">
                                                </Setter>
                                            </Trigger>
                                            <Trigger Property="IsSelected" Value="true">
                                                <Setter Property="Background" Value="{StaticResource RowBackgroundSelectedBrush}" />
                                            </Trigger>
                                         
                                        </Style.Triggers>
                                    </Style>
                                   
                                </DataGrid.RowStyle>
                               
                                <DataGrid.Columns>
                                    <!--<DataGridCheckBoxColumn   Header="{Translate FiTransactionItemAddL}" IsReadOnly="{Binding Path=FiTransactionItemCheckForReadOnly}"  Binding="{Binding FiTransactionItemAdd, Mode=TwoWay}"  
                                                              Width="40" MinWidth="40" />-->
                                    <DataGridTemplateColumn Header="{Translate FiTransactionItemAddL}" Width="SizeToCells"  >
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <CheckBox Name="checked" IsChecked="{Binding FiTransactionItemAdd,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"  IsEnabled="{Binding Path=FiTransactionItemCheckForReadOnly}" Checked="checked_Checked" Unchecked="checked_Unchecked" >
                                                                                                        </CheckBox>
                                               
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTextColumn   Header="{Translate FiTransactionDocNoL}"  Binding="{Binding DocumentNo}" 
                                                              Width="100" MinWidth="40" />
                                    <DataGridTextColumn   Header="{Translate FiTransactionBookingDescriptionL}"  Binding="{Binding BookingDescriptionHeader}" 
                                                              Width="100" MinWidth="40" />
                                    <DataGridTextColumn   Header="{Translate FiAccountNoL}"  Binding="{Binding FiAccountNo}" 
                                                              Width="100" MinWidth="40" />
                                    <DataGridTextColumn   Header="{Translate FiAccountNameL}"  Binding="{Binding FiAccountNameCur}" 
                                                              Width="150" MinWidth="40" />
                                    <DataGridTextColumn Header="{Translate BookingDescriptionL}"   Width="100" MinWidth="40" />
                                    <!--<DataGridTextColumn Header="{Translate ValueDateL}" Binding="{Binding Path=ValueDate, StringFormat=dd/MM/yyyy}"  CellStyle="{StaticResource CenterAlignedCellStyle}" MinWidth="70" Width="70"/>-->
                                    <DataGridTextColumn Header="{Translate FiAccountAmountDebitL}"  Binding="{Binding Path=FiAccountAmountDebit, StringFormat=N2}"  Width="*" CellStyle="{StaticResource AlwaysRightAlignedCellStyle}"/>

                                </DataGrid.Columns>
                            </DataGrid>

                            <TextBox Grid.Row="2"  HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,3,3" Name="DebitTotal" Width="120" Text="{Binding DebitTransactionSum, StringFormat=N2, Mode=OneWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}" IsReadOnly="True" Style="{StaticResource P2TextBoxStyle}" Height="23" HorizontalContentAlignment="Right" FlowDirection="LeftToRight"/>
                        </Grid>
                    </Border>



                    <Border Grid.Row="1" Margin="5,0,5,5"   VerticalAlignment="Stretch" BorderThickness="1" CornerRadius="2,2,2,2" BorderBrush="#FF6893CF">
                        <Grid ShowGridLines="False">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20"/>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="34"/>
                            </Grid.RowDefinitions>

                            <Label Grid.Row="0" Name="CreditL" Width="120" Height="28" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0" Content="{Translate CreditL}" FontWeight="Bold" />

                            <DataGrid Grid.Row="1" Margin="3,0,3,0" 
                                         Name="FiChequeFiTransactionItemCreditList" 
                                         ItemsSource="{Binding FiChequeCreditTransactionItems}"  
                                                                               
                                         Style="{DynamicResource CuberryDataGridStyle}"
                                         VerticalAlignment="Top" >
                                <DataGrid.RowStyle>
                                    <Style TargetType="DataGridRow">
                                        <Setter Property="IsEnabled" Value="{Binding Path=FiTransactionItemCheckForReadOnly}"/>
                                        <Style.Triggers>
                                            <Trigger Property="IsEnabled" Value='false'>
                                                <Setter Property="Background" Value="LightGray">
                                                </Setter>
                                            </Trigger>
                                            <Trigger Property="IsSelected" Value="true">
                                                <Setter Property="Background" Value="{StaticResource RowBackgroundSelectedBrush}" />
                                            </Trigger>
                                           
                                        </Style.Triggers>

                                    </Style>
                                </DataGrid.RowStyle>

                                <DataGrid.Columns>
                                    <!--<DataGridCheckBoxColumn   Header="{Translate FiTransactionItemAddL}" IsReadOnly="{Binding Path=FiTransactionItemCheckForReadOnly}" Binding="{Binding FiTransactionItemAdd}" 
                                                              Width="40" MinWidth="40" />-->
                                    <DataGridTemplateColumn Header="{Translate FiTransactionItemAddL}" Width="SizeToCells"  >
                                        <DataGridTemplateColumn.CellTemplate>
                                        
                                            <DataTemplate >



                                                <CheckBox  Name="creditcheck" IsChecked="{Binding FiTransactionItemAdd,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" IsEnabled="{Binding Path=FiTransactionItemCheckForReadOnly}" Checked="creditcheck_Checked" Unchecked="creditcheck_Unchecked" />
                                              
                                             

                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>

                                    <DataGridTextColumn   Header="{Translate FiTransactionDocNoL}"   Binding="{Binding DocumentNo}" 
                                                              Width="100" MinWidth="40" />
                                    <DataGridTextColumn   Header="{Translate FiTransactionBookingDescriptionL}"  Binding="{Binding BookingDescriptionHeader}" 
                                                              Width="100" MinWidth="40" />
                                    <DataGridTextColumn   Header="{Translate FiAccountNoL}"   Binding="{Binding FiAccountNo}" 
                                                              Width="100" MinWidth="40" />
                                    <DataGridTextColumn   Header="{Translate FiAccountNameL}"  Binding="{Binding FiAccountNameCur}" 
                                                              Width="150" MinWidth="40" />
                                    <DataGridTextColumn Header="{Translate BookingDescriptionL}"  Binding="{Binding Path=BookingDescription}" Width="100" MinWidth="40" />
                                    <!--<DataGridTextColumn Header="{Translate ValueDateL}" Binding="{Binding Path=ValueDate, StringFormat=dd/MM/yyyy}"  CellStyle="{StaticResource CenterAlignedCellStyle}" MinWidth="70" Width="70"/>-->
                                    <DataGridTextColumn Header="{Translate FiAccountAmountCreditL}" Binding="{Binding Path=FiAccountAmountCredit, StringFormat=N2}"   Width="*" CellStyle="{StaticResource AlwaysRightAlignedCellStyle}"/>
                                </DataGrid.Columns>
                            </DataGrid>

                            <TextBox Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,3,3" Name="CreditTotal"  Width="120" Text="{Binding CreditTransactionSum, StringFormat=N2, Mode=OneWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}" IsReadOnly="True" Style="{StaticResource P2TextBoxStyle}" HorizontalContentAlignment="Right" FlowDirection="LeftToRight" Height="23"/>

                        </Grid>
                    </Border>
                </Grid>


            </Grid>
        </Border>

        <!-- Row 2: End -->


        <!-- Row 3: Bottom: Status Bar Start -->
        <Border Grid.Row="3" Grid.Column="0" Style="{StaticResource P2StatusStripBorderStyle}" >
            <Grid Grid.Row="3" Grid.Column="0" Style="{StaticResource P2StatusStripGridStyle}">
                <basec:P2StatusStrip x:Name="StatusStrip" MessageStack2="{Binding MessageStack}"  Grid.Column="0" Grid.Row="3" Height="Auto" Width="Auto" Background="White" HorizontalAlignment="Left" ContentStringFormat=""></basec:P2StatusStrip>
                <TextBox Name="Status" Grid.Column="0" Grid.Row="3" Height="Auto" Width="Auto" Background="White" HorizontalAlignment="Right" Text="{Binding StatusName, Mode=OneWay}" IsReadOnly="True" BorderBrush="Transparent" />
            </Grid>
        </Border>
        <!-- Row 3: End -->
    </Grid>
</Window>